package cloth.dao;

import java.sql.SQLException;
import java.util.ArrayList;

import org.springframework.orm.ibatis.SqlMapClientTemplate;

import cloth.vo.NoticeVO;



public class NoticeDAO {
	
	private SqlMapClientTemplate client;
	public NoticeDAO(){}

	public void setSqlMapClientTemplate(SqlMapClientTemplate client){
		this.client = client;
	}
	
	public ArrayList<NoticeVO> selectNotice()throws SQLException{
		return (ArrayList)client.queryForList("getNotices");
	}
	public ArrayList<NoticeVO> selectNoticePerPage(int page)throws SQLException{
		return (ArrayList)client.queryForList("selectNoticePerPage",page);
	}
	public int selectTotalNotice()throws SQLException{
		return (Integer) client.queryForObject("selectTotalNotice");
	}
	
	public NoticeVO selectNoticeById(int no)throws SQLException{
		return (NoticeVO) client.queryForObject("selectNoticeById",no);
	}
	public int insertNotice(NoticeVO nvo)throws SQLException{
		return (Integer) client.insert("insertNotice",nvo);
	}
	public int updateNotice(NoticeVO nvo)throws SQLException{
		int i =client.update("updateNotice",nvo);
		return i;
	}
	public int deleteNotice(int no)throws SQLException{
		return client.delete("deleteNotice", no);
	}
	public int deleteNoticeByWriter(String m_id)throws SQLException{
		return client.delete("deleteNoticeByWriter", m_id);
	}
}
